package com.hx.zhg.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.lang.reflect.Field;

public class LibUtil {

    private static final Logger log = LoggerFactory.getLogger(FileUtilExt.class);

    /**
     * 设置LibraryPath：
     *
     * @param path 根目录为jar包所在目录
     */
    public static void setDefaultJavaLibraryPath(String path) {
        try {
            System.setProperty("java.library.path", SystemPropertiesUtil.getLibraryPath() + ":" + SystemPropertiesUtil.getUserDir() + File.separator + path);
            Field fieldSysPath = null;
            fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
            fieldSysPath.setAccessible(true);
            fieldSysPath.set(null, null);
        } catch (Exception e) {
            log.error("【*】设置JNI动态连接库失败！！");
            e.printStackTrace();
        }

    }
}
